<template>
  <div class="navList">
    <div v-bind:class="{listTab:true ,active:isChecked==-1}" style="margin-left: 0;" @click="changeisChecked(-1)">
      <span>推荐</span>
    </div>
    <!--  -->
    <div :class="{listTab:true,active:isChecked==index}" v-for=" i,index in navData" :key="i.categoryId" @click="changeisChecked(index)">
      <span>{{ i.categoryName }}</span>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from "vue"
export default defineComponent({
  name: 'HeaderNav',
})
</script>

<script lang="ts" setup>
import { storeToRefs } from "pinia";
import { ref } from "vue";

// import { onMounted, } from 'vue';
import { useHomeStore } from '@/stores/home'

const homeStore = useHomeStore()
let { navData } = storeToRefs(homeStore)
let isChecked = ref(-1)
// 点击切换active
function changeisChecked(i:any){
  isChecked.value = i
  console.log(isChecked.value);
  
}


</script>

<style scoped lang="less">

.navList {
  height: 30px;
  padding: 0 25px 0 10px;
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  // box-sizing: border-box;
  width: 375px;
  // .element::-webkit-scrollbar { width: 0 !important }
  .listTab {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: 24px;
    &.active{
      border-bottom: 2px solid #dd1a21;
    }
    span {
      display: inline-block;
      padding: 0 8px;
      line-height: 30px;
      font-size: 14px;
      text-align: center;
      font-family: PingFangSC-Light,helvetica,Heiti SC;
    }
  }
}
</style>